package org.six.background.service.impl;

import org.six.background.mapper.ShoptypeMapper;
import org.six.background.pojo.ShopExample;
import org.six.background.pojo.Shoptype;
import org.six.background.pojo.ShoptypeExample;
import org.six.background.service.ShoptypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoptypeServiceImpl implements ShoptypeService {
    @Autowired(required = false)
    private ShoptypeMapper shoptypeMapper;
    @Autowired(required = false)
    private Shoptype shoptype;

    @Override
    public List<Shoptype> shoptypeshow() {
        return shoptypeMapper.selectByExample(null);
    }

    @Override
    public int shoptypeadd(Shoptype shoptype) {

            int i = shoptypeMapper.insertSelective(shoptype);
            return i;

    }

    @Override
    public List<Shoptype> shoptypeByname(String shoptypename) {
        return shoptypeMapper.shoptypenames(shoptypename);
    }

    @Override
    public int shoptypedelete(Shoptype shoptype) {
        if (shoptype.getShoptypeid()!=null){
            int i = shoptypeMapper.deleteByPrimaryKey(shoptype.getShoptypeid());
            return i;
        }else {
            return 0;
        }
    }

    @Override
    public int shoptypeupdata(Shoptype shoptype) {
        ShoptypeExample shoptypeExample = new ShoptypeExample();

        ShoptypeExample.Criteria c = shoptypeExample.createCriteria();
        c.andShoptypeidEqualTo(shoptype.getShoptypeid());
            int i = shoptypeMapper.updateByPrimaryKeySelective(shoptype);
            return i;
    }
}
